package com.crb.crm.manage.message.common;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.Assert;

import java.util.Arrays;
import java.util.Optional;

/**
 * Package: com.gulimall.thrid.party.msg.enums
 * Description：消息模板
 * Author: huangjian
 * Date:  2020/6/18 14:49
 * Modified By:
 */
@AllArgsConstructor
@Getter
public enum SAGTemplate {
    REGISTER_SUCCESS("REGISTER_SUCCESS","用户注册成功"),
    USER_MODIFY_PWD("USER_MODIFY_PWD","用户修改密码"),
    USER_WITHDRAW("USER_WITHDRAW","用户提现"),
    USER_RECHARGE("USER_RECHARGE","用户充值"),
    USER_LOGIN("USER_LOGIN","用户登录"),
    ;
    private String name;
    private String desc;
    public static SAGTemplate findByName(String name){
        Optional<SAGTemplate> smgTempltete = Arrays.stream(SAGTemplate.values()).filter(temp->temp.getName().equals(name)).findFirst();
        Assert.isTrue(smgTempltete.isPresent(),"模板【"+name+"】找不到映射的枚舉，請檢查");
        return smgTempltete.get();
    }
}
